<?php

/**
 * 站内消息操作
 *
 * Created by PhpStorm.
 * User: evan
 * Date: 16/9/25
 * Time: 下午5:13
 */
class Operate extends MY_Api_Controller
{
    /**
     * 发送站内消息
     */
    public function send()
    {
        $uid     = $this->uid;
        $to_uid  = (int)$this->input->get_post('to_uid');
        $type    = (int)$this->input->get_post('type');
        $message = trim($this->input->get_post('message'));


        $this->load->service('message/service_message_operate');
        $data = $this->service_message_operate->send($uid, $to_uid, $message, $type);


        unset($data['data']['ip']);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 消息状态处理
     */
    public function status_change()
    {
        $uid    = $this->uid;
        $did    = (int)$this->input->get_post('did');
        $mid    = (int)$this->input->get_post('mid');
        $type   = (int)$this->input->get_post('type');
        $status = (int)$this->input->get_post('status');


        $this->load->service('message/service_message_operate');
        $data = $this->service_message_operate->status_change($uid, $did, $mid, $type, $status);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 删除对话
     */
    public function delete_dialogue()
    {
        $uid = $this->uid;
        $did = (int)$this->input->get_post('did');


        $this->load->service('message/service_message_operate');
        $data = $this->service_message_operate->delete_dialogue($did, $uid);


        $this->json_output($data['data'], $data['status']);
    }
}